<html>
<head>
    <meta charset="utf-8">
    <title>首页</title>
    <#assign base=request.contextPath  />
    <#setting  number_format="0.##"/>
    <title>评论管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${base}/backstage/layui/css/layui.css" media="all">
    <script src="${base}/backstage/js/jquery-1.8.3.min.js"></script>
    <script src="${base}/backstage/layui/layui.js"></script>
    <script src="${base}/backstage/js/feng.js"></script>
    <script>
        var base =  "${base}";
    </script>
    <script src="${base}/backstage/js/ipNameUrl.js"></script>
    <style>
        /*给数据表格加高*/
        .layui-table-cell{
            height:50%;
        }
    </style>
</head>
<body>
<br>
<#--<div class="demoTable" style="margin-left: 15px;">-->
<#--    <form class="layui-form " action="">-->
<#--        <div class="layui-form-item">-->
<#--            <div class="layui-inline">-->
<#--                <label>商品分类</label>-->
<#--                <div class="layui-inline">-->
<#--                    <input class="layui-input" name="name" id="name" placeholder="请输入商品分类名称" autocomplete="off">-->
<#--                </div>-->
<#--            </div>-->
<#--            <button class="layui-btn" onclick="sech()" data-method="offset"-->
<#--                    type="button">查询-->
<#--            </button>-->
<#--        </div>-->
<#--    </form>-->
<#--</div>-->
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">
    <button class="layui-btn" lay-event="del" onclick="onDelete('{{d.id}}')"
            style="background: red;color: #FFFFFF">删除
    </button>

</script>
<script type="text/html" id="toolbarDemo">
<#--    <form class="layui-form " action="">-->
<#--        <div class="layui-form-item" style="margin-left: 15px;">-->
<#--            <div class="layui-btn-group">-->
<#--                <button class="layui-btn" id="btn2" data-method="offset" type="button">添加</button>-->
<#--            </div>-->
<#--        </div>-->
<#--    </form>-->
</script>
<script>
    layui.use(['table', 'form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , $ = layui.jquery
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , table = layui.table;

        var whereData = {}
        whereData.name = $("#name").val();

        table.render({
            skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , elem: '#test'
            ,where:whereData
            , url: '${base}/admin/comment/selectMyPage'
            , toolbar: '#toolbarDemo'
            ,cols:[[
                {field:'id', title: '序号',templet:function(val){
                        return val.LAY_INDEX
                    },width:80,align:'center'},
                {field:'phone', title: '手机号', align:'center'},
                {field:'openid', title: 'openid', align:'center'},
                {field:'goodName', title: '商品名称', align:'center'},
                {field:'comment', title: '评论', align:'center'},
                {field:'createTime', title: '创建时间',templet:function(val){
                        if(val.createTime==undefined){
                            return "";
                        }
                        return changeDateFormat(val.createTime);
                    },  align:'center'},
                {field: 'right', title: '操作', toolbar: '#barDemo', align: 'center'}
            ]]
            , id: 'testReload'
            , page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                , theme: '#1AB394'
                , limit: 10
            }
        });

        //添加
        var active = {
            offset: function (othis) {
                var type = othis.data('type')
                    , text = othis.text();
                window.location.href = '${base}/admin/commodityClassification/commodityClassification_add.html';
            }
        };
        $('#btn2').on('click', function () {
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });

        //编辑弹出层
        table.on('tool(test)', function (obj) {
            var layEvent = obj.event;
            if (layEvent == "edit") {
                var data = obj.data;
                window.location.href = '${base}/admin/commodityClassification/commodityClassification_edit.html?id=' + data.id;
            }
        });

    })
    //删除
    function onDelete(id) {
        layer.confirm('真的要删除吗?', function (index) {
            $.ajax({
                type: "POST",
                url: "${base}/admin/commodityClassification/deleteById",
                data: {id: id},
                sync: false,
                success: function (data) {
                    if (data.code === 200) {
                        layer.msg(data.msg)
                        setTimeout(function () {
                            window.location.reload();
                        }, 500)
                    } else {
                        layer.msg(data.msg)
                    }

                }
            });
        });
    }
    //搜索
    function sech() {
        var whereData = {}
        whereData.name = $("#name").val();
        //表刷新方法
        var table = layui.table;
        table.reload('testReload', {
            url: '${base}/admin/commodityClassification/selectMyPage'
            , where: whereData
        });
    }

    function icon(id) {
        $.ajax({
            type: "POST",
            url: "${base}/admin/commodityClassification/set_upIcon",
            data: {id: id},
            sync: false,
            success: function (data) {
                if (data.code === 200) {
                    layer.msg(data.msg)
                    setTimeout(function () {
                        window.location.reload();
                    }, 500)
                } else {
                    layer.msg(data.msg)
                }

            }
        });
    }
</script>

</body>

</html>


